﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace NUnitResults
{
    /// <summary>
    /// An IStreamProvider which reads from a results file.
    /// </summary>
    public class FileStreamProvider : IStreamProvider
    {
        /// <summary>
        /// Gets the path to the results file.
        /// </summary>
        public String Name { get; private set; }

        /// <summary>
        /// Creates a new FileStreamProvider.
        /// </summary>
        /// <param name="filePath">The path to the file.</param>
        public FileStreamProvider(String filePath)
        {
            if (filePath == null)
            {
                throw new ArgumentNullException("filePath");
            }

            Name = filePath;
        }

        #region IStreamProvider Members

        /// <summary>
        /// Gets a FileStream which can be used to read the file.
        /// </summary>
        /// <returns></returns>
        public Stream GetStream()
        {
            return new FileStream(Name, FileMode.Open);
        }

        #endregion
    }
}
